package com.wd.tw.job;

import com.wd.tw.service.BooleanCountService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @className: EventScheduler
 * @description: TODO 类描述
 * @author: liumingkun
 * @date: 2024/11/17
 **/
@Component
public class EventScheduler {

    private final static Logger logger = LoggerFactory.getLogger(EventScheduler.class);

    @Resource
    BooleanCountService countService;

    //每秒执行一次，读取电梯运行状态
    @Scheduled(fixedDelay = 1000 * 1)
    public void countStateJob() {
        logger.info("begin to get count service!");
        countService.countState();
    }

    //每分钟将电梯运行情况写入数据库
    @Scheduled(cron = "0 * * * * ?")
    public void storeRunSate() {
        logger.info("begin to write count service!");
        countService.writeState();
    }

    @Scheduled(cron = "1 0 0 * * ?")
    public void resetJob(){
        logger.info("begin to reset  service!");
        countService.resetState();
    }
}
